package cn.yonghui.hyd.plugin

import com.android.build.gradle.AppExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.internal.reflect.Instantiator
import org.gradle.invocation.DefaultGradle

class DemoPlugin implements Plugin<Project> {

    @Override
    void apply(Project project) {
        println("######DemoPlugin apply######")
        Instantiator ins = ((DefaultGradle) project.getGradle()).getServices().get(Instantiator)
        def args = [ins] as Object[]
        DemoExtensionConfig extension = project.extensions.create("demo", DemoExtensionConfig, args)
        AppExtension appExtension = project.extensions.findByType(AppExtension.class)
        appExtension.registerTransform(new DemoTransform(extension))
    }
}